package com.example.demo.order;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class OrderController {

    @Autowired
    private RedisTemplete redisTemplete;

    @PostMapping("/order/create")
    public String createOrder(@RequestBody OrderMessage orderMessage){

        //创建订单
        //redis中获取账户信息
        ValueOperation operation=(ValueOperation<k,v>)redisTemplete.opsForValue();
        String userMessage=operation.get(orderMessage.getUserId());
        //根据用户id校验账户信息，获取账户信息等操作
        check(userMessage);
        //执行创建订单
        orderMessage.setUserMessage(userMessage);
        //执行订单创建
        return "SUCCESS";
    }

    void check(String userMessage){
        //获取用户信息 校验存在 有效 扣减等操作

    }
}
